package com.abc.controller;

import com.abc.entity.Programme;
import com.abc.service.IProgrammeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/programme")
@Api(tags = "节目管理相关接口")
public class AdminProgrammeController {
    
    @Autowired
    private IProgrammeService programmeService;

    @GetMapping
    @ApiOperation(value = "获取所有节目", notes = "返回所有节目的列表")
    public List<Programme> getAllProgrammes() {
        return programmeService.list();
    }

    @PostMapping
    @ApiOperation(value = "发布节目", notes = "根据提供的节目详情和用户邮箱列表，发布节目")
    public boolean publishProgramme(
            @ApiParam(value = "节目对象", required = true) @RequestBody Programme programme,
            @ApiParam(value = "用户邮箱列表", required = true) @RequestParam String[] userEmails) throws Exception {
        return programmeService.publishProgramme(programme, userEmails);
    }
}
